package com.amigo.helper;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;





public class JsonFileUtility  {
	
	static File fileo = new File(Constants.base_storage_path);
	
	public static void CreateAndSaveFile(String params, String mJsonResponse) {
		File fileo = new File(Constants.base_storage_path);
    	
    	
	    try {
	    if (!fileo.exists())
	    	fileo.mkdirs();
	        FileWriter file = new FileWriter(fileo + "/" +  params);
	        file.write(mJsonResponse);
	        file.flush();
	        file.close();
	    } catch (IOException e) {
	        e.printStackTrace();
	    }
	}
	
	public static String ReadJsonData(String params) {
		String mResponse = "init" ;
	    try {
	        
	        FileInputStream is = new FileInputStream(fileo + "/" + params);
	        int size = is.available();
	        byte[] buffer = new byte[size];
	        is.read(buffer);
	        is.close();
	         mResponse = new String(buffer);
	        return mResponse;
	    } catch (IOException e) {
	        
	        e.printStackTrace();
	    }
	    return mResponse ;
	}
	
	public static void  DeleteJsonData(String params) {
		
		   
        
        File del_file = new File(fileo + "/" + params);
        del_file.delete();
         
   
    
}

}
